<template>
  <view class="login-container">
    <!-- Logo区域 -->
    <view class="logo-section">
      <view class="logo-circle">
        <text class="logo-text">甩单</text>
      </view>
    </view>

    <!-- 按钮区域 -->
    <view class="button-section">
      <!-- 手机号快捷登录按钮 -->
      <button
        class="login-btn primary-btn"
        open-type="getPhoneNumber"
        @getphonenumber="handleSmartPhoneLogin"
        :loading="isLoading"
      >
        手机号快捷登录
      </button>

      <!-- 测试登录按钮（开发环境显示） -->
      <button
        class="login-btn test-btn"
        @click="handleTestLogin"
        :loading="isTestLoading"
        v-if="showTestLogin"
      >
        🧪 测试登录
      </button>

      <!-- 暂不登录按钮 -->
      <button
        class="login-btn secondary-btn"
        @click="handleSkipLogin"
      >
        暂不登录
      </button>
    </view>

    <!-- 服务条款 -->
    <view class="terms-section">
      <checkbox-group @change="handleTermsChange">
        <checkbox
          value="agreed"
          :checked="agreedToTerms"
          class="terms-checkbox"
        />
      </checkbox-group>
      <text class="terms-text">
        登录即视为同意
        <text class="terms-link" @click="showServiceTerms">《服务条款》</text>
        和
        <text class="terms-link" @click="showPrivacyPolicy">《接单隐私政策》</text>
      </text>
    </view>

    <!-- 用户信息完善界面（登录后显示） -->
    <view v-if="showUserProfileSetup" class="profile-setup-overlay">
      <view class="profile-setup-modal">
        <text class="setup-title">完善个人信息</text>
        <text class="setup-desc">设置您的头像和昵称，更好地展示个人形象</text>
        
        <!-- 头像选择区域 -->
        <view class="avatar-section">
          <text class="section-label">头像</text>
          <button 
            class="avatar-picker"
            open-type="chooseAvatar"
            @chooseavatar="onChooseAvatar"
          >
            <image 
              class="avatar-preview" 
              :src="selectedAvatarUrl || '/static/images/default-avatar.png'" 
              mode="aspectFill"
            />
            <text class="avatar-tip">点击选择头像</text>
          </button>
        </view>
        
        <!-- 昵称输入区域 -->
        <view class="nickname-section">
          <text class="section-label">昵称</text>
          <input
            type="nickname"
            class="nickname-input"
            placeholder="请输入您的昵称"
            v-model="userNickname"
            @blur="onNicknameBlur"
            maxlength="20"
          />
          <text class="nickname-tip">昵称将用于聊天显示，最多20个字符</text>
        </view>
        
        <!-- 按钮区域 -->
        <view class="setup-buttons">
          <button 
            class="confirm-setup-btn"
            @click="confirmUserProfileSetup"
            :disabled="!userNickname.trim()"
          >
            完成设置
          </button>
          
          <button 
            class="skip-setup-btn"
            @click="skipUserProfileSetup"
          >
            跳过，稍后设置
          </button>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { authAPI, userAPI, utils } from '@/utils/api.js'
import globalNotificationManager from '@/utils/globalNotificationManager.js'
import pageNotificationListener from '@/utils/pageNotificationListener.js'

// 响应式数据
const isLoading = ref(false)
const isTestLoading = ref(false)
const agreedToTerms = ref(false)
const showTestLogin = ref(true) // 开发环境显示测试登录按钮
const showUserProfileSetup = ref(false) // 用户信息设置界面
const selectedAvatarUrl = ref('') // 选择的头像URL
const userNickname = ref('') // 用户输入的昵称

const DEFAULT_NICKNAME = '微信用户'
const SERVER_AVATAR_HOST = 'https://yaotuss.com'

const isHttpUrl = (url) => /^https?:\/\//i.test(url || '')
const isHostedByServer = (url) => isHttpUrl(url) && url.startsWith(SERVER_AVATAR_HOST)
const isTemporaryAvatar = (url) => {
  if (!url || isHostedByServer(url)) {
    return false
  }
  const normalizedUrl = url.trim()
  if (!normalizedUrl) {
    return false
  }
  if (normalizedUrl.startsWith('wxfile://') || normalizedUrl.startsWith('file://')) {
    return true
  }
  return /^https?:\/\/tmp\//i.test(normalizedUrl)
}
const shouldUploadAvatarToServer = (url) => isTemporaryAvatar(url)

const isProfileComplete = (profile) => {
  if (!profile) return false
  const avatarUrl = profile.avatar_url
  if (!avatarUrl) return false
  if (shouldUploadAvatarToServer(avatarUrl)) return false
  return true
}

const getStoredProfile = () => {
  try {
    const storedUser = uni.getStorageSync('userInfo')
    if (storedUser) {
      return {
        nickname: storedUser.nickname || '',
        avatar_url: storedUser.avatar_url || ''
      }
    }
  } catch (error) {
    console.error('读取本地用户资料失败:', error)
  }
  return null
}

const resolveProfileForSkip = () => {
  const storedProfile = getStoredProfile()
  if (!storedProfile) {
    return null
  }

  const profilePayload = {}
  if (storedProfile.nickname) {
    profilePayload.nickname = storedProfile.nickname
  }
  if (storedProfile.avatar_url && !shouldUploadAvatarToServer(storedProfile.avatar_url)) {
    profilePayload.avatar_url = storedProfile.avatar_url
  }

  return Object.keys(profilePayload).length > 0 ? profilePayload : null
}

const presentProfileSetupModal = (userInfo) => {
  showUserProfileSetup.value = true
  if (userInfo?.nickname && userInfo.nickname !== DEFAULT_NICKNAME) {
    userNickname.value = userInfo.nickname
  } else {
    userNickname.value = ''
  }
  if (userInfo?.avatar_url && !shouldUploadAvatarToServer(userInfo.avatar_url)) {
    selectedAvatarUrl.value = userInfo.avatar_url
  } else {
    selectedAvatarUrl.value = ''
  }
}

const processLoginResult = async (loginResult, loginSuccessOptions = {}) => {
  if (!loginResult) {
    throw new Error('登录结果无效')
  }
  if (!loginResult.success || !loginResult.data) {
    throw new Error(loginResult.message || '登录失败')
  }

  const serverUserInfo = loginResult.data.user || null
  if (isProfileComplete(serverUserInfo)) {
    await handleLoginSuccess(loginResult.data, '登录成功', loginSuccessOptions)
    return true
  }

  await handleLoginSuccess(loginResult.data, '登录成功', {
    ...loginSuccessOptions,
    deferNavigation: true,
    skipToast: true
  })

  presentProfileSetupModal(serverUserInfo)

  uni.showToast({
    title: '请完善头像和昵称',
    icon: 'none'
  })

  return false
}

const ensureAvatarUploadedToServer = async (avatarSource) => {
  if (!shouldUploadAvatarToServer(avatarSource)) {
    return avatarSource
  }

  try {
    const uploadResult = await userAPI.uploadAvatar(avatarSource)
    if (uploadResult.success && uploadResult.data?.url) {
      return uploadResult.data.url
    }
    console.warn('头像上传接口返回失败:', uploadResult.message)
  } catch (error) {
    console.error('上传头像到服务器失败:', error)
  }
  return ''
}

// 生命周期钩子
onMounted(() => {
  // 检查是否已经登录
  checkLoginStatus()
})

// 方法定义
/**
 * 检查登录状态
 */
const checkLoginStatus = () => {
  const token = uni.getStorageSync('token')
  if (token) {
    // 已登录，直接跳转到消息页面
    navigateToChat()
  }
}

/**
 * 处理手机号登录（自动获取）
 */
const handlePhoneLogin = async (e) => {
  if (!agreedToTerms.value) {
    uni.showToast({
      title: '请先同意服务条款',
      icon: 'none'
    })
    return
  }

  // 检查是否获取到手机号授权码
  if (!e.detail.code) {
    uni.showToast({
      title: '获取手机号失败，请重试',
      icon: 'none'
    })
    return
  }

  isLoading.value = true

  try {
    // 第一步：获取微信登录code
    const loginRes = await getWechatLoginCode()
    console.log('获取微信登录code成功:', loginRes.code)

    // 第二步：获取用户信息（需要用户授权）
    const userProfile = await getUserProfile()
    console.log('获取用户信息成功:', userProfile)

    // 第三步：调用后端登录接口，传递登录code、手机号授权码和用户信息
    const loginResult = await callLoginAPI(loginRes.code, e.detail.code, userProfile)

    if (!loginResult.success) {
      throw new Error(loginResult.message || '登录失败')
    }

    const loginSuccessOptions = {}
    if (shouldUploadAvatarToServer(userProfile.avatar_url)) {
      loginSuccessOptions.rawAvatarSource = userProfile.avatar_url
    }

    const completed = await processLoginResult(loginResult, loginSuccessOptions)
    if (completed) {
      return
    }
  } catch (error) {
    console.error('登录失败:', error)
    uni.showToast({
      title: error.message || '登录失败，请重试',
      icon: 'none'
    })
  } finally {
    isLoading.value = false
  }
}

/**
 * 智能手机号登录（优先自动获取，失败则手动输入）
 */
const handleSmartPhoneLogin = async (e) => {
  if (!agreedToTerms.value) {
    uni.showToast({
      title: '请先同意服务条款',
      icon: 'none'
    })
    return
  }

  // 检查是否获取到手机号授权码
  if (!e.detail.code) {
    uni.showToast({
      title: '获取手机号失败，请手动输入',
      icon: 'none'
    })
    // 回退到手动输入
    handleManualPhoneLogin()
    return
  }

  isLoading.value = true

  try {
    // 第一步：获取微信登录code
    const loginRes = await getWechatLoginCode()
    console.log('获取微信登录code成功:', loginRes.code)

    // 第二步：尝试通过后端安全地获取手机号
    const phoneResult = await authAPI.getPhoneNumber(e.detail.code)

    if (phoneResult.success) {
      const phoneNumber = phoneResult.data.purePhoneNumber
      console.log('自动获取手机号成功:', phoneNumber)

      const autoLoggedIn = await tryAutoCompleteLogin(loginRes.code, phoneNumber)
      if (autoLoggedIn) {
        isLoading.value = false
        return
      }

      const loginResult = await callManualPhoneLoginAPI(
        loginRes.code,
        phoneNumber,
        resolveProfileForSkip()
      )

      const completed = await processLoginResult(loginResult)
      isLoading.value = false
      if (completed) {
        return
      }

      return
    } else {
      throw new Error(phoneResult.message || '获取手机号失败')
    }
  } catch (error) {
    console.error('自动获取手机号失败:', error)

    // 如果是权限问题，提示用户并回退到手动输入
    if (error.message && error.message.includes('权限')) {
      uni.showModal({
        title: '提示',
        content: '小程序暂未获得自动获取手机号权限，是否手动输入手机号登录？',
        success: (res) => {
          if (res.confirm) {
            handleManualPhoneLogin()
          }
        }
      })
    } else {
      uni.showToast({
        title: '获取手机号失败，请重试',
        icon: 'none'
      })
    }
  } finally {
    isLoading.value = false
  }
}

/**
 * 处理手机号登录（手动输入）
 */
const handleManualPhoneLogin = async () => {
  if (!agreedToTerms.value) {
    uni.showToast({
      title: '请先同意服务条款',
      icon: 'none'
    })
    return
  }

  // 弹出输入框让用户输入手机号
  uni.showModal({
    title: '手机号登录',
    editable: true,
    placeholderText: '请输入手机号',
    success: async (res) => {
      if (res.confirm && res.content) {
        const phoneNumber = res.content.trim()

        // 简单的手机号验证
        if (!/^1[3-9]\d{9}$/.test(phoneNumber)) {
          uni.showToast({
            title: '请输入正确的手机号',
            icon: 'none'
          })
          return
        }

        // 使用获取到的手机号进行登录
        await performPhoneLogin(phoneNumber)
      }
    }
  })
}

/**
 * 获取微信登录code
 */
const getWechatLoginCode = () => {
  return new Promise((resolve, reject) => {
    uni.login({
      provider: 'weixin',
      success: (res) => {
        if (res.code) {
          resolve(res)
        } else {
          reject(new Error('获取登录code失败'))
        }
      },
      fail: () => {
        reject(new Error('微信登录失败'))
      }
    })
  })
}

/**
 * 获取用户信息（使用用户手动输入的信息）
 */
const getUserProfile = () => {
  return new Promise((resolve) => {
    // 微信已不再支持自动获取真实昵称，使用用户手动输入的信息
    resolve({
      nickname: userNickname.value.trim() || DEFAULT_NICKNAME,
      avatar_url: selectedAvatarUrl.value || '',
      gender: 0,
      country: '',
      province: '',
      city: ''
    })
  })
}

/**
 * 处理头像选择
 */
const onChooseAvatar = (e) => {
  const avatarUrl = e.detail.avatarUrl
  console.log('选择的头像:', avatarUrl)

  if (!avatarUrl) {
    uni.showToast({
      title: '获取头像失败',
      icon: 'none'
    })
    return
  }

  // 更新选择的头像URL
  selectedAvatarUrl.value = avatarUrl
  
  uni.showToast({
    title: '头像选择成功',
    icon: 'success',
    duration: 1000
  })
}

/**
 * 昵称输入失焦处理
 */
const onNicknameBlur = () => {
  // 清理昵称前后空格
  userNickname.value = userNickname.value.trim()
}

/**
 * 确认用户信息设置
 */
const confirmUserProfileSetup = async () => {
  if (!userNickname.value.trim()) {
    uni.showToast({
      title: '请输入昵称',
      icon: 'none'
    })
    return
  }

  try {
    uni.showLoading({
      title: '保存中...'
    })

    const trimmedNickname = userNickname.value.trim()
    const rawAvatarSource = (selectedAvatarUrl.value || '').trim()
    const userProfileData = {
      nickname: trimmedNickname
    }

    if (rawAvatarSource) {
      userProfileData.avatar_url = rawAvatarSource
    }

    if (rawAvatarSource) {
      const uploadedUrl = await ensureAvatarUploadedToServer(rawAvatarSource)
      if (uploadedUrl) {
        userProfileData.avatar_url = uploadedUrl
      } else {
        delete userProfileData.avatar_url
      }
    }

    const updateResult = await userAPI.updateUser(userProfileData)
    
    if (!updateResult.success) {
      throw new Error(updateResult.message || '保存失败')
    }

    const currentUserInfo = uni.getStorageSync('userInfo') || {}
    Object.assign(currentUserInfo, userProfileData)
    if (userProfileData.avatar_url) {
      currentUserInfo.avatar = userProfileData.avatar_url
    }
    uni.setStorageSync('userInfo', currentUserInfo)

    uni.hideLoading()
    uni.showToast({
      title: '信息保存成功',
      icon: 'success'
    })

    showUserProfileSetup.value = false

    setTimeout(() => {
      navigateToChat()
    }, 1500)
  } catch (error) {
    uni.hideLoading()
    console.error('操作失败:', error)
    uni.showToast({
      title: error.message || '操作失败，请重试',
      icon: 'none'
    })
  }
}

/**
 * 跳过用户信息设置
 */
const skipUserProfileSetup = async () => {
  try {
    showUserProfileSetup.value = false
    navigateToChat()
  } catch (error) {
    uni.hideLoading()
    console.error('登录失败:', error)
    uni.showToast({
      title: error.message || '登录失败，请重试',
      icon: 'none'
    })
  }
}





/**
 * 调用后端登录API（自动获取手机号）
 */
const callLoginAPI = async (code, phoneCode, userProfile) => {
  return await authAPI.phoneLogin(code, phoneCode, userProfile)
}

/**
 * 执行手机号登录（通用方法）
 */
const performPhoneLogin = async (phoneNumber) => {
  isLoading.value = true

  try {
    // 第一步：获取微信登录code
    const loginRes = await getWechatLoginCode()
    console.log('获取微信登录code成功:', loginRes.code)

    const autoLoggedIn = await tryAutoCompleteLogin(loginRes.code, phoneNumber)
    if (autoLoggedIn) {
      return
    }

    const loginResult = await callManualPhoneLoginAPI(
      loginRes.code,
      phoneNumber,
      resolveProfileForSkip()
    )

    const completed = await processLoginResult(loginResult)
    if (completed) {
      return
    }
  } catch (error) {
    console.error('登录失败:', error)
    uni.showToast({
      title: error.message || '登录失败，请重试',
      icon: 'none'
    })
  } finally {
    isLoading.value = false
  }
}

/**
 * 调用后端登录API（手动输入手机号）
 */
const callManualPhoneLoginAPI = async (code, phoneNumber, userProfile) => {
  return await authAPI.manualPhoneLogin(code, phoneNumber, userProfile)
}

/**
 * 处理测试登录
 */
const handleTestLogin = async () => {
  isTestLoading.value = true

  try {
    console.log('🧪 开始测试登录...')

    // 调用测试登录接口
    const loginResult = await authAPI.testLogin()

    if (loginResult.success) {
      console.log('✅ 测试登录成功:', loginResult.data.user)
      await handleLoginSuccess(loginResult.data, '测试登录成功')
    } else {
      throw new Error(loginResult.message || '测试登录失败')
    }
  } catch (error) {
    console.error('测试登录失败:', error)
    uni.showToast({
      title: error.message || '测试登录失败，请重试',
      icon: 'none'
    })
  } finally {
    isTestLoading.value = false
  }
}

/**
 * 处理暂不登录
 */
const handleSkipLogin = () => {
  // 清除可能存在的登录信息
  uni.removeStorageSync('token')
  uni.removeStorageSync('userInfo')

  // 跳转到消息页面（游客模式）
  navigateToChat()
}

/**
 * 跳转到消息页面
 */
const navigateToChat = () => {
  // 登录成功后启动全局审核通知轮询
  console.log('🚀 登录成功，启动审核通知轮询')
  globalNotificationManager.onUserLogin()
  
  // 启动页面监听器
  pageNotificationListener.start()
  
  uni.redirectTo({
    url: '/pages/chat/chat'
  })
}

const handleLoginSuccess = async (loginData, toastMessage = '登录成功', options = {}) => {
  if (!loginData) {
    return
  }

  const {
    rawAvatarSource,
    deferNavigation = false,
    skipToast = false
  } = options

  uni.setStorageSync('token', loginData.token)

  let finalUserInfo = { ...loginData.user }

  if (rawAvatarSource) {
    const uploadedUrl = await ensureAvatarUploadedToServer(rawAvatarSource)
    if (uploadedUrl && uploadedUrl !== finalUserInfo.avatar_url) {
      try {
        const updateResult = await userAPI.updateUser({ avatar_url: uploadedUrl })
        if (updateResult.success) {
          finalUserInfo = {
            ...finalUserInfo,
            avatar_url: uploadedUrl,
            avatar: uploadedUrl
          }
        }
      } catch (error) {
        console.error('登录后更新头像失败:', error)
      }
    }
  }

  if (finalUserInfo.avatar_url && !finalUserInfo.avatar) {
    finalUserInfo.avatar = finalUserInfo.avatar_url
  }

  uni.setStorageSync('userInfo', finalUserInfo)
  uni.removeStorageSync('pendingLoginData')
  uni.hideLoading()

  if (!skipToast) {
    uni.showToast({
      title: toastMessage,
      icon: 'success'
    })
  }

  if (!deferNavigation) {
    setTimeout(() => {
      navigateToChat()
    }, 1500)
  }
}

const tryAutoCompleteLogin = async (loginCode, phoneNumber) => {
  const storedProfile = getStoredProfile()
  if (!isProfileComplete(storedProfile)) {
    return false
  }

  try {
    const loginResult = await callManualPhoneLoginAPI(loginCode, phoneNumber, storedProfile)
    if (loginResult.success) {
      await handleLoginSuccess(loginResult.data)
      return true
    }
    console.warn('使用本地资料自动登录失败:', loginResult.message)
    return false
  } catch (error) {
    console.error('使用本地资料自动登录失败:', error)
    return false
  }
}

/**
 * 处理服务条款勾选
 */
const handleTermsChange = (e) => {
  console.log('服务条款勾选状态变化:', e.detail.value)
  agreedToTerms.value = e.detail.value.length > 0
}

/**
 * 显示服务条款
 */
const showServiceTerms = () => {
  uni.showModal({
    title: '服务条款',
    content: '这里是服务条款的内容...',
    showCancel: false
  })
}

/**
 * 显示隐私政策
 */
const showPrivacyPolicy = () => {
  uni.showModal({
    title: '接单隐私政策',
    content: '这里是隐私政策的内容...',
    showCancel: false
  })
}
</script>

<style scoped>
.login-container {
  min-height: 100vh;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
  padding: 0 60rpx;
}

.logo-section {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 200rpx;
}

.logo-circle {
  width: 200rpx;
  height: 200rpx;
  background-color: #22c55e;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-text {
  color: white;
  font-size: 48rpx;
  font-weight: bold;
}

.button-section {
  margin-bottom: 100rpx;
}

.login-btn {
  width: 100%;
  height: 88rpx;
  border-radius: 44rpx;
  font-size: 32rpx;
  margin-bottom: 32rpx;
  border: none;
}

.primary-btn {
  background-color: #22c55e;
  color: white;
}

.primary-btn:active {
  background-color: #16a34a;
}

.secondary-btn {
  background-color: transparent;
  color: #22c55e;
  border: 2rpx solid #22c55e;
}

.secondary-btn:active {
  background-color: #f0fdf4;
}

.test-btn {
  background-color: #f59e0b;
  color: white;
}

.test-btn:active {
  background-color: #d97706;
}

.terms-section {
  display: flex;
  align-items: flex-start;
  margin-bottom: 60rpx;
  padding: 0 20rpx;
}

.terms-checkbox {
  margin-right: 16rpx;
  margin-top: 4rpx;
}

.terms-text {
  font-size: 24rpx;
  color: #666;
  line-height: 1.5;
  flex: 1;
}

.terms-link {
  color: #22c55e;
  text-decoration: underline;
}

/* 用户信息设置界面样式 */
.profile-setup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.profile-setup-modal {
  background: white;
  border-radius: 20rpx;
  padding: 60rpx 40rpx;
  margin: 40rpx;
  width: 600rpx;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
}

.setup-title {
  display: block;
  font-size: 40rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 16rpx;
  text-align: center;
}

.setup-desc {
  display: block;
  font-size: 28rpx;
  color: #666;
  margin-bottom: 60rpx;
  line-height: 1.5;
  text-align: center;
}

/* 头像选择区域 */
.avatar-section {
  margin-bottom: 50rpx;
}

.section-label {
  display: block;
  font-size: 32rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 20rpx;
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30rpx;
  background: #f8f9fa;
  border: 2rpx dashed #d0d7de;
  border-radius: 12rpx;
  width: 100%;
}

.avatar-picker:active {
  background: #f1f3f4;
}

.avatar-preview {
  width: 120rpx;
  height: 120rpx;
  border-radius: 50%;
  background: #e5e5e5;
  margin-bottom: 16rpx;
}

.avatar-tip {
  font-size: 24rpx;
  color: #666;
}

/* 昵称输入区域 */
.nickname-section {
  margin-bottom: 60rpx;
}

.nickname-input {
  width: 100%;
  padding: 24rpx 20rpx;
  font-size: 32rpx;
  border: 2rpx solid #e5e5e5;
  border-radius: 8rpx;
  background: white;
  margin-bottom: 12rpx;
}

.nickname-input:focus {
  border-color: #22c55e;
  outline: none;
}

.nickname-tip {
  display: block;
  font-size: 24rpx;
  color: #666;
  line-height: 1.4;
}

/* 按钮区域 */
.setup-buttons {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.confirm-setup-btn {
  width: 100%;
  height: 88rpx;
  background: #22c55e;
  color: white;
  border: none;
  border-radius: 8rpx;
  font-size: 32rpx;
  font-weight: 600;
}

.confirm-setup-btn:active {
  background: #16a34a;
}

.confirm-setup-btn:disabled {
  background: #d1d5db;
  color: #9ca3af;
}

.skip-setup-btn {
  width: 100%;
  height: 76rpx;
  background: transparent;
  color: #666;
  border: 2rpx solid #e5e5e5;
  border-radius: 8rpx;
  font-size: 28rpx;
}

.skip-setup-btn:active {
  background: #f5f5f5;
}
</style>
